<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>模版1数据列表</title>
  <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
</head>
<body class="layui-layout-body" >
<div class="layui-layout layui-layout-admin">

<div class="layui-body">
	<!-- 内容主体区域 -->
	<blockquote class="layui-elem-quote" data-th-text="${channel.name}"></blockquote>
	<a data-th-onclick="'openNoticeConfig(' + ${channelId} + ')'"  class="layui-btn">公告设置</a>
	<a th:href="@{/index_page/channel/list}"  class="layui-btn">返回频道列表</a>
	<br/><br/>
	<img alt="模版1" style="width: 434px;height: 179px;" th:src="@{/images/template_01.jpg}">
    <div class="layui-table-body layui-table-main">
    <table class="layui-table" >
	<!--  	<colgroup>
	    	<col width="150">
	    	<col width="200">
	    	<col>
	 	</colgroup> -->
	  	<thead>
	    	<tr>
				<th>序号</th>
				<th><b>位置</b></th>
				<th><b>标题</b></th>
				<th><b>状态</b></th>
				<th><b>更新时间</b></th>
				<th><b>操作人</b></th>
				<th><b>操作</b></th>
	    	</tr> 
		</thead>
	  	<tbody>
	  		 <tr>
	  		 	<td class="layui-table-cell">1</td>
	  		 	<td class="layui-table-cell">位置1</td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp1 == null} ? '' : ${tmp1.title}"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp1 == null} ? '' : (${tmp1.status eq 1} ? '已上架':'未上架')"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp1 == null} ? '' : ${#calendars.format(tmp1.operateTime, 'yyyy-MM-dd  HH:mm:ss')}"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp1 == null} ? '' : ${tmp1.operator}"></td>
	  		 	<td class="layui-table-cell">
	  		 		<a class="layui-btn  layui-btn-xs"
	  		 			th:href="@{/channel_data/tmp1/edit(channelId=${channelId},location=1)}">编辑</a>
	  		 			
	  		 		<a class="layui-btn  layui-btn-xs" data-th-if="${tmp1 != null}" 
	  		 			data-th-onclick="'changeStatus(' + ${channelId} + ',' + ${tmp1.id} + ',' + ${tmp1.status} + ')'"
	  		 			data-th-text="${tmp1.status eq 1} ? '下架':'上架'"></a>
	  		 	</td>
	  		 </tr>
	  		 <tr>
	  		 	<td class="layui-table-cell">2</td>
	  		 	<td class="layui-table-cell">位置2</td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp2 == null} ? '' : ${tmp2.title}"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp2 == null} ? '' : (${tmp2.status eq 1} ? '已上架':'未上架')"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp2 == null} ? '' : ${#calendars.format(tmp2.operateTime, 'yyyy-MM-dd  HH:mm:ss')}"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp2 == null} ? '' : ${tmp2.operator}"></td>
	  		 	<td class="layui-table-cell">
	  		 		<a class="layui-btn  layui-btn-xs"
	  		 			th:href="@{/channel_data/tmp1/edit(channelId=${channelId},location=2)}">编辑</a>
	  		 			
	  		 		<a class="layui-btn  layui-btn-xs" data-th-if="${tmp2 != null}"
	  		 			data-th-onclick="'changeStatus(' + ${channelId} + ',' + ${tmp2.id} + ',' + ${tmp2.status} + ')'"
	  		 			data-th-text="${tmp2.status eq 1} ? '下架':'上架'"></a>
	  		 	</td>
	  		 </tr>
	  		 <tr>
	  		 	<td class="layui-table-cell">3</td>
	  		 	<td class="layui-table-cell">位置3</td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp3 == null} ? '' : ${tmp3.title}"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp3 == null} ? '' : (${tmp3.status eq 1} ? '已上架':'未上架')"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp3 == null} ? '' : ${#calendars.format(tmp3.operateTime, 'yyyy-MM-dd  HH:mm:ss')}"></td>
	  		 	<td class="layui-table-cell" data-th-text="${tmp3 == null} ? '' : ${tmp3.operator}"></td>
	  		 	<td class="layui-table-cell">
	  		 		<a class="layui-btn  layui-btn-xs"
	  		 			th:href="@{/channel_data/tmp1/edit(channelId=${channelId},location=3)}">编辑</a>
	  		 			
	  		 		<a class="layui-btn  layui-btn-xs" data-th-if="${tmp3 != null}" 
	  		 			data-th-onclick="'changeStatus(' + ${channelId} + ',' + ${tmp3.id} + ',' + ${tmp3.status} + ')'"
	  		 			data-th-text="${tmp3.status eq 1} ? '下架':'上架'"></a>
	  		 	</td>
	  		 </tr>
	  	</tbody>
	</table>
	</div>
	<div style="height: 70px"></div>
</div>
  
</div>

<script th:src="@{/layui/jquery.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script th:inline="javascript">
//JavaScript代码区域
var contextRoot = /*[[@{/}]]*/ '';
$(document).ready(function(){ 
	$(".layui-body").css({"left": "10px","top": "10px"});
}); 
layui.use(['layer', 'form', 'element'], function(){
	var layer = layui.layer;
});

function openNoticeConfig(channelId) {
	layer.open({
		title: '公告设置',
		area: ['460px', '350px'],
	  	type: 2, 
	  	content: contextRoot +'/index_page/channel_notice_config/edit?channelId=' + channelId
	});
}

function changeStatus(channelId, tmpDataId, status) {
	var tipMsg = status == 0 ? '确定上架么？' : '确定下架么？';
	layer.confirm(tipMsg, {btnAlign: 'c', title:'提示'}, function(index){
		var res = $.ajax({
			url:contextRoot+"/channel_data/tmp1/change_status"
			, data:"channelId=" + channelId + "&tmpDataId=" + tmpDataId +"&status=" + status
			, method:"post"
			, async:false
		});
		
		if(res.responseJSON.meta.code == 0)
			window.location.reload();
		else
			layer.msg(res.responseJSON.meta.message);
		
	});
}
</script>
</body>
</html>